(deftemplate number (slot pi) (slot pz))
(deftemplate suma (slot pi) (slot pz))

(assert (number (pi 1) (pz 30)))
(assert (number (pi 2) (pz 74)))
(assert (number (pi 5) (pz 12)))
(assert (number (pi 6) (pz 12)))
(assert (suma (pi 0) (pz 0)))

(defrule printare
	(number (pi ?i) (pz ?z))
    =>   
    (printout t "Nr " ?i "," ?z crlf)
)

(defrule suma
	?idn<-(number (pi ?i))
    ?idfapt<-(suma (pi ?s))
    =>
    (bind ?s1 (+ ?i ?s))
    (modify ?idfapt (pi ?s1))
    (retract ?idn)
)

(defrule print
    (suma (pi ?s))
    =>
    (printout t "Suma este " ?s)
)

(run)
